﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <script type="text/javascript">
        function callPageMthodWithjQueryAjax(argument) {
            $.ajax({
                type: "POST",
                url: "Default.aspx/GetDateTime",
                data: "{'myName':'Satyavir','me':'Yadav'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function (result) {
                    alert(result.d);
                },
                error: function (result) {
                    alert("Error while retriving value");
                    isValid = false;
                }

            });
        }

        $(document).ready(function () {
            $("#uploadbutton").click(function () {
                var filename = $("#file").val();
                $.ajax({
                    type: "POST",
                    url: "Default.aspx/SaveFile",
                    enctype: 'multipart/form-data',
                    data: { file: filename },
                    success: function () {
                        alert("Data Uploaded: ");
                    }
                });
            });
           }); 
    </script>
    <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                Server Time :<asp:Label Text="text" ID="lblDateTime" runat="server" />
            </td>
        </tr>
        <tr>
            <td>
                File data:<div id="myDiv">
                </div>
                <input type="button" name="name" value="Get New Time" onclick="callPageMthodWithjQueryAjax()" />
            </td>
        </tr>
        <tr>
            <td>
                <span>File</span>
                <input type="file" id="file" name="file" size="10" />
            </td>
            <td>
                <input id="uploadbutton" type="button" value="Upload" />
            </td>
        </tr>
    </table>
</asp:Content>
